#include "ObObject.h"

ObObject::ObObject(){
	mID		= 0;
	mInfo	= 0;
	mWidth	= 16.0f;
	mHeight = 16.0f;
	mPos	= D3DXVECTOR3(0.0f,0.0f,0.0f);
	mSpritePos		= D3DXVECTOR3(0.0f,0.0f,0.0f);
	mRotation		= 0;
	mNeedDispose	= false;
	mNeedCollision	= true;
}

bool ObObject::setId(int nid){
	mID = nid;
	return true;
}

int	ObObject::getId(){
	return mID;
}

bool ObObject::setInfo(int ninfo){
	mInfo = ninfo;
	return true;
}

int	ObObject::getInfo(){
	return mInfo;
}
float ObObject::getWidth(){
	return mWidth;
}

float ObObject::getHeight(){
	return mHeight;
}

bool ObObject::getDisposeStatus(){
	return mNeedDispose;
}

void ObObject::setPos(D3DXVECTOR3& pos){
	mPos = pos;
}

D3DXVECTOR3& ObObject::getPos(){
	return mPos;
}

int ObObject::getHashId(){
	return mHashID;
}

std::string	ObObject::getSaveString(){
	std::string str = std::to_string((int)mPos.x) + " " + std::to_string((int)mPos.y) + " " + std::to_string(mID) + " " + std::to_string(mInfo) + " "  + std::to_string(mHashID);
	return str;
}

void ObObject::setHashId(int nid){
	mHashID = nid;
}

D3DXVECTOR3& ObObject::getCenter(){
	return mCenter;
}

void ObObject::setCenter(D3DXVECTOR3& center){
	mCenter = center;
}

RECT ObObject::calRenderRECT(D3DXVECTOR3 spritePos, float width, float height){
	LONG x,y;
	x = (LONG) spritePos.x;
	y = (LONG) spritePos.y;
	LONG w,h;
	w = (LONG)(width/2);
	h = (LONG)(height/2);

	RECT rect;
	rect.left = x - w;
	rect.right = x + w;
	rect.top = y - h;
	rect.bottom = y + h;
	return rect;
}